package cn.gson.fengboot.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "qdep_from", schema = "springboot", catalog = "")
public class QdepFrom {
    private Integer depId;
    private String depName;
    private QdepFrom upDep;
    private String depRemark;
    private Collection<QempFrom> qempdepid;
    private Collection<QroleFrom> qroledepid;
    private Collection<QmenusEntity> menuslist;

    @Id
    @Column(name = "dep_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public Integer getDepId() {
        return depId;
    }

    public void setDepId(Integer depId) {
        this.depId = depId;
    }


    @Basic
    @Column(name = "dep_name")
    public String getDepName() {
        return depName;
    }

    public void setDepName(String depName) {
        this.depName = depName;
    }



    @ManyToOne
    @JoinColumn(name = "dep_upid",referencedColumnName = "dep_id")
    public QdepFrom getUpDep() {
        return upDep;
    }

    public void setUpDep(QdepFrom upDep) {
        this.upDep = upDep;
    }

    @Basic
    @Column(name = "dep_remark")
    public String getDepRemark() {
        return depRemark;
    }

    public void setDepRemark(String depRemark) {
        this.depRemark = depRemark;
    }

    @OneToMany(mappedBy = "depId")
    public Collection<QroleFrom> getQroledepid() {
        return qroledepid;
    }
    public void setQroledepid(Collection<QroleFrom> qroledepid) {
        this.qroledepid = qroledepid;
    }

    @OneToMany(mappedBy = "depId")
    public Collection<QempFrom> getQempdepid() {
        return qempdepid;
    }
    public void setQempdepid(Collection<QempFrom> qempdepid) {
        this.qempdepid = qempdepid;
    }

    @ManyToMany
    @JoinTable(name="ddepandmenus",
            joinColumns={@JoinColumn(name="dep_id")},
            inverseJoinColumns = {@JoinColumn(name="menus_id")
            })
    public Collection<QmenusEntity> getMenuslist() {
        return menuslist;
    }

    public void setMenuslist(Collection<QmenusEntity> menuslist) {
        this.menuslist = menuslist;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        QdepFrom qdepFrom = (QdepFrom) o;
        return depId == qdepFrom.depId &&
                Objects.equals(depName, qdepFrom.depName);
    }


    @Override
    public String toString() {
        return "QdepFrom{" +
                "depId=" + depId +
                ", depName='" + depName + '\'' +
                ", depRemark='" + depRemark + '\'' +
                ", qempdepid=" + qempdepid +
                ", qroledepid=" + qroledepid +
                ", menuslist=" + menuslist +
                '}';
    }
}
